<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
  <style type="text/css">
    body, html, #allmap {
      width: 100%;
      height: 100%;
      overflow: hidden;
      margin: 0;
      font-family: "微软雅黑";
    }
  </style>
  <script src="http://api.map.baidu.com/api?v=2.0&ak=F19q5OcuWjjkMN55MFhqBU1h3GFfW0S3"></script>
  <title>带文字标签的覆盖物</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
  // 百度地图API功能
  var locinfo = [
    {name: '广州市黄埔区斗塘路8号米丝莱办公楼5楼', lon: [113.571014, 23.211164]},
    {name: '黄埔区瑞和路39号纳金科技园G5座5层', lon: [113.512759, 23.157991]},
    {name: '广州市黄埔区揽月路8号东软大厦255单元', lon: [113.452082, 23.167573]},
    {name: '广东省广州市天河区科韵路24-26号', lon: [113.380276, 23.129642]},
    {name: '广东省广州市天河区天和软件园高唐新建区软件路孵化中心二期', lon: [113.420643, 23.178292]},
    {name: '海珠区中山大学B座', lon: [113.297583, 23.099339]}
  ]


  var map = new BMap.Map("allmap");
  var point = new BMap.Point(113.37042, 23.121549);
  map.centerAndZoom(point,12);
  map.enableScrollWheelZoom(true);

  for (var i = 0; i < locinfo.length; i++) {
    var info = locinfo[i];
    console.log(info)
    var point = new BMap.Point(info.lon[0], info.lon[1]);
    var marker = new BMap.Marker(point);
    map.addOverlay(marker);

    var label = new BMap.Label(info.name, {offset: new BMap.Size(20, -10)});
    marker.setLabel(label);
  }
  var myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), {
    offset: new BMap.Size(20, -10), // 指定定位位置
    imageOffset: new BMap.Size(0, 0 - 11 * 25) // 设置图片偏移
  });
  var marker2 = new BMap.Marker( new BMap.Point(113.37042, 23.121549),{icon:myIcon});  // 创建标注
  map.addOverlay(marker2);
  var label2 = new BMap.Label('我的房间', {offset: new BMap.Size(20, -10)});
  marker2.setLabel(label2);
  label2.setStyle({
    color : "red",
    fontSize : "12px",
    height : "20px",
    lineHeight : "20px",
    fontFamily:"微软雅黑"
  });
  marker2.setLabel(label2);

  //
//  map.centerAndZoom(point, 12);
//  var marker = new BMap.Marker(point);  // 创建标注
//  map.addOverlay(marker);              // 将标注添加到地图中
//
//  var label = new BMap.Label("我是文字标注哦",{offset:new BMap.Size(20,-10)});
//  marker.setLabel(label);



</script>
